
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="content-type" content="no-cache, must-revalidate" />
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT"/>
    <title>更新密码</title>

    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/nav.css">
    <link rel="stylesheet" href="../css/font-awesome.css">
    <link rel="stylesheet" href="../css/element/index.css">

    <style>

    </style>
</head>
<body>
<div id="wrapper" v-cloak>
    <!--导航栏-->

    <!-- 主体 -->
    <div >
        <!-- 头部开始 -->

        <!-- 头部结束 -->

        <!-- 主体开始 -->
        <div style="padding: 0 20px">
            <div>
                <div style="color: #666; font-weight: bold; border-bottom: 1px solid #ccc; padding: 10px 0; margin-bottom: 20px; font-size: 30px;">修改密码</div>
            </div>

            <!-- 表格主体-->
            <div style="margin-top: 10px">
                <div style="border: 1px solid #19a97b;">
                    <div style="padding: 5px; border-bottom: 1px solid #19a97b; color: white; background-color: #19a97b;">修改密码</div>
                    <div style="border: 1px solid #ccc; padding: 10px">
                        <form role="form" style="width: 300px">
                            <input type="hidden" id="id" name="id" v-model="entity.id">
                            <div class="form-group input-group">
                                <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                                <input type="password" class="form-control" v-model="entity.mima" placeholder="原密码"/>
                            </div>
                            <div class="form-group input-group">
                                <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                                <input type="password" class="form-control" v-model="entity.newMima" placeholder="新密码"/>
                            </div>
                            <div class="form-group input-group">
                                <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                                <input type="password" class="form-control" v-model="entity.new2Mima" placeholder="确认密码"/>
                            </div>
                            <div style="text-align: center">
                                <a href="javascript:void(0)" @click="updateMima()" class="btn btn-primary">提交</a>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <!-- 表格主体结束-->
        </div>
        <!-- 主体结束 -->

    </div>
</div>

<script src="../js/jquery-1.10.2.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/nav.js"></script>
<script src="../js/my.js"></script>
<script src="../js/vue2.6.11/vue.min.js"></script>
<script src="../js/vue2.6.11/axios.js"></script>
<script src="../js/element/index.js"></script>

<script>
    function msg(type, msg) {
        Vue.prototype.$message({
            type: type, // success（成功）、warning（警告）, error(错误)
            message: msg,
            duration: 2000,
            offset: 100,
            center: true,
        })
    }

    new Vue({
        el: '#wrapper',
        data: {
            user: {},
            authority: [],
            objs: [],
            entity: {}
        },
        created: function () {

            this.user = JSON.parse(localStorage.getItem('user'));

            axios.get("/getAccountInfo").then(res => {
                if (res.data.code === '0') {
                    this.entity.id = res.data.data.id;
                } else {
                    msg('error', res.data.msg);
                }

            });

            axios.get("/authority").then(res => {
                if (res.data.code === '0') {
                    this.authority = res.data.data;
                } else {
                    msg('error', res.data.msg);
                }
            });

        },
        methods: {
            updateMima: function () {
                if (!this.entity.mima || this.entity.mima === '') {
                    msg('warning', '请输入原密码');
                    return;
                }
                if (!this.entity.newMima || this.entity.newMima === '') {
                    msg('warning', '请输入新密码');
                    return;
                }
                if (!this.entity.new2Mima || this.entity.new2Mima === '') {
                    msg('warning', '请确认密码');
                    return;
                }
                if (this.entity.newMima !== this.entity.new2Mima) {
                    msg('warning', '两次输入的新密码不一致');
                    return;
                }
                axios.put("/updateMima", this.entity).then(res => {
                    if (res.data.code === '0') {
                        msg('success', '密码修改成功，退出重新登录后有效，为安全考虑，系统已帮您自动退出，请您按F5重新打开网页登录！');
                       // window.location = '/end/page/login.html';
                    } else {
                        msg('error', res.data.msg);
                    }
                })
            },
            logout() {
                logout();
            }
        }
    })
</script>
</body>
</html>
